﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using XRPGLibrary;
using XRPGLibrary.Controls;

namespace myRPG.GameScreens
{
    public class TitleScreen : BaseGameState
    {
        #region Field region//Texture2D为图片加载对象
        Texture2D backgroundImage;
        LinkLabel startLabel;
        #endregion
        #region Constructor region
        public TitleScreen(Game game, GameStateManager manager)
            : base(game, manager)
        {
        }
        #endregion
        #region XNA Method region
        protected override void LoadContent()
        {
            ContentManager Content = GameRef.Content;
            backgroundImage = Content.Load<Texture2D>(@"Backgrounds\startBg");//背景图片加载
            base.LoadContent();
            //初始化LinkLabel控件
            startLabel = new LinkLabel();
            startLabel.Position = new Vector2(300, 480);
            startLabel.Text = "Press Enter to Begin";
            startLabel.Color = Color.Brown;
            startLabel.TabStop = true;
            startLabel.HasFocus = true;
            //selected事件
            startLabel.Selected += new EventHandler(startLabel_Selected);
            ControlManager.Add(startLabel);
        }
        public override void Update(GameTime gameTime)
        {
            ControlManager.Update(gameTime, PlayerIndex.One);
            base.Update(gameTime);
        }
        public override void Draw(GameTime gameTime)
        {
            GameRef.SpriteBatch.Begin();
            base.Draw(gameTime);
            GameRef.SpriteBatch.Draw(
            backgroundImage, GameRef.ScreenRectangle,
           Color.White);
            ControlManager.Draw(GameRef.SpriteBatch);
            GameRef.SpriteBatch.End();
        }
        #endregion

        private void startLabel_Selected(object sender, EventArgs e)
        {
            StateManager.PushState(GameRef.StartMenuScreen);
        }
    }
}